
//- table form controls 
+partial('controls')
    .ui.buttons 
        +unless('readonly')
            btn(
                on-buttonclick="toggleEditing"
                class="{{#if editTooltip }}red{{else}}blue{{/if}} {{#if editable}}red{{/if}}"
                active="{{editable}}"
                tooltip="Düzenle"
                )
                i.write.icon 
            .or
        
        btn(on-buttonclick="newOrderClose" tooltip="Kapat")
            i.remove.icon
    .ui.horizontal.divider 


//- tableview partials 
+partial('renderMarkup').
    {{#if typeof . === 'string'}}
        {{> { template: . } }}
    {{else}}
        {{{ . }}}
    {{/if}}


//- Header part
+iff('firstRunDone')
    | {{>header}}
    //- End Of Header

    .ui.segments
        +if('selectedFilter !== "all"')
            .ui.attached.warning.message.segment
                .header 
                    i.warning.icon 
                    | Filtered Content 
                p.
                    You are seeing a filtered content. 
                    #[btn.blue.mini(on-buttonclick="setFilter" value="all") #[i.remove.icon] Clear Filter]
                    
        +if('addingNew')
            h3.ui.attached.header #[i.edit.icon] New Document 
            .ui.segment
                | {{> editForm }}

        .ui.segment
            r-table
                r-head
                    r-row                    
                        +each('columnList')
                            r-head-col {{>renderMarkup}}                    
                //- -----------------------------------------------
                //- body of table 
                //- -----------------------------------------------
                r-body
                    +each('tableview_visible:i')
                        tr(
                            data-anchor="{{.id}}"
                            on-click!="['clicked', this]"
                            class!="{{#if isDisabled(.id)}}disabled{{/if}}"
                            )    
                            //- -----------------------------------------------
                            //- edit form
                            //- -----------------------------------------------
                            +iff('isEditingLine(.id)')
                                td(colspan="{{ columnList.length }}")
                                    | {{>controls}}
                                    | {{>editForm}}

                            //- -----------------------------------------------
                            //- view form
                            //- -----------------------------------------------
                            +elif('isViewingRow(.id)')
                                td(colspan="{{ columnList.length }}")                            
                                    | {{>controls}}
                                    | {{>viewForm}}
                                
                            //- -----------------------------------------------
                            //- normal rows 
                            //- -----------------------------------------------
                            +else
                                +each(".cols:colindex")
                                    td(data-th="{{columnList[colindex]}}")
                                        +iff('colindex === 0 && isLastClicked(tableview_visible[i].id)')
                                            +iff('isOpeningNow(tableview_visible[i].id)')
                                                //- if row is opening, mark first column with teal ribbon label 
                                                .ui.teal.ribbon.label {{>renderMarkup}}
                                            +else
                                                //- if row is opening, mark first column with orange ribbon label 
                                                .ui.orange.ribbon.label {{>renderMarkup}}
                                            +endif
                                        +else.
                                            {{>renderMarkup}}
                                        +endif
                            +endif

                +if('settings.pageSize > 0')
                    +if('(tableview.length / settings.pageSize) > 1')
                        tfoot
                            tr
                                th(colspan="{{ columnList.length }}")
                                    .ui.right.floated.pagination.menu
                                        +each('range(1, Math.ceil(tableview.length / settings.pageSize)):i')
                                            a(on-click="@.fire('selectPage', i)" class!="item {{#if currPage === i}}blue{{/if}}") {{ . }}

                            +if('openingRowMsg')
                                tr 
                                    th(colspan="{{ columnList.length }}")
                                        | {{ openingRowMsg }}

+else
    //- display "Loading" indicator till first fetch of the tabledata  
        .ui.active.centered.inline.big.text.loader Yükleniyor  
    .ui.icon.message 
        i.notched.circle.loading.icon 
        .content 
            .header Just one second 
        p We're fetching table content for you. 
        
+endif

.ui.page.dimmer.table-section-of-data-table
    .content
        .center 
            .ui.active.big.text.loader
                p {{ openingRowMsg }}
                btn.small.inverted.red.icon(on-buttonclick="newOrderClose" tooltip="Kapat") #[i.remove.icon] Cancel
